/**
 * Created by Administrator on 2016/7/1.
 */
"use strict";
swan_pc
    .controller("ListShowController",function($scope,Clip,TimeExchange,$state,$rootScope,Excel,$timeout){
        $scope.predicate = 'id';
        $scope.reverse = true;
        $scope.page = 1;
        Clip.query({page: $scope.page - 1, size: 500, sort: [$scope.predicate + ',' + ($scope.reverse ? 'asc' : 'desc'), 'id']},
            function(result, headers) {
                $scope.totalItems = headers('X-Total-Count');
                $scope.$parent.clips = result;
                //console.log("agenda"+$scope.clips);
            });
        $scope.TimeShow=function(time){
            if(time==null){
                return "";
            }
            var date=new Date(time);
            var timer=date.toString();
            timer=TimeExchange.StringtoLocalTime(timer);
            //console.log("clipserch "+time + " " + " "+date + " "+ timer);
            return timer;
        };
        $scope.ClipDetailShow=function(id){
            //console.log("id:"+id);
            $rootScope.presentEventid=id;
            $state.go("agendadetailshow");
        }
        $scope.exportToExcel=function(tableId){ // ex: '#my-table'
            $scope.exportHref=Excel.tableToExcel(tableId,'sheet name');
            $timeout(function(){location.href=$scope.exportHref;},100); // trigger download
        }
    })